Generic Exception Handling and the Java Monad
نویسندگان
چکیده
We develop an equational definition of exception monads that characterizes Moggi’s exception monad transformer. This axiomatization is then used to define an extension of previously described monadindependent computational logics by abnormal termination. Instantiating this generic formalism with the Java monad used in the LOOP project yields in particular the known Hoare calculi with abnormal termination and JML’s method specifications; this opens up the possibility of extending these formalisms by hitherto missing computational features such as I/O and nondeterminism.
منابع مشابه
Parametrized Exceptions
Following the paradigm of encapsulation of side effects via monads, the Java execution mechanism has been described by the socalled Java monad, encorporating essentially stateful computation and exceptions, which are heavily used in Java control flow. A technical problem that appears in this model is the fact that the return exception in Java is parametrized by the return value, so that method ...
متن کاملA logical interpretation of Java-style exceptions
This paper presents a novel, type-based exception analysis for EC (an Exception Calculus)—a higher-order, typed programming language with first-class, Java-style exceptions. EC exceptions are predeclared and are subject to a nominal subtyping relation. Every exception has its own type, and generic exception handling is performed by handling a supertype of all applicable exceptions. Typing is ba...
متن کاملCompleteness of monad-based dynamic logic
Monads are used in functional programming as a means of modeling and encapsulating computational effects at an appropriate level of abstraction. In previous work, we have introduced monad-based dynamic logic and have used it for the specification and verification of various monadic functional-imperative algorithms over different monads. The semantics of this logic was originally defined over pa...
متن کاملA Modal Calculus for Exception Handling
The exception monad, while an adequate mechanism for providing the denotational semantics of exceptions, is somewhat awkward to program with. Just as any other monad, it forces a programming style in which exceptional computations are explicitly sequentialized in the program text. In addition, values of computation types must usually be tested before use, in order to determine if they correspon...
متن کاملMonad-Based Logics for Computational Effects
The presence of computational effects, such as state, store, exceptions, input, output, non-determinism, backtracking etc., complicates the reasoning about programs. In particular, usually for each effect (or each combination of these), an own logic needs to be designed. Monads are a well-known tool from category theory that originally has been invented for studying algebraic structures. Monads...
متن کامل